import datetime
import logging

from redis import StrictRedis


class Config:
    DEBUG = True  # 开启调试
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/info15"  # 设置数据库URI
    SQLALCHEMY_TRACK_MODIFICATIONS = True  # 跟踪数据变化
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    SESSION_TYPE = "redis"  # 存储方式
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)  # 创建保存session的redis管理器
    SECRET_KEY = "Uhjb/5ZqfVcYNGCze4r3IjrOxGR3TekcTjP3nLBEJ8X8AkyJQPYFT7y0gmjZhU/o"
    SESSION_USE_SIGNER = True  # 是否加密
    PERMANENT_SESSION_LIFETIME = datetime.timedelta(days=7)  # session的保存时间(其实session一直保存,只是设置了cookie中sessionid的过期时间)


class DevelopmentConfig(Config):
    DEBUG = True  # 开启调试
    LOG_LEVEL = logging.DEBUG


class ProductConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR


class TestConfig(Config):
    DEBUG = True  # 开启调试
    TESTING = True  # 开启单元测试
    LOG_LEVEL = logging.DEBUG


conf = {"dev": DevelopmentConfig,
        "pro": ProductConfig,
        "test": TestConfig}